package com.bjpowernode.web.controller;

import com.bjpowernode.enums.Code;
import com.bjpowernode.web.service.SmsService;
import com.bjpowernode.web.views.ResultView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @description:
 * @author: panDeng_Zhu
 * @time: 2022/11/1 21:03
 */

@CrossOrigin
@Api(tags = "短信服务")
@RestController
public class SmsController {

    @Resource
    private SmsService smsService;

    //发送短信
    @ApiOperation(value = "发送注册短信",notes = "给指定的手机号发送短信")
    @GetMapping("/v1/sms/send/register")
    public ResultView senRegisterSms (String phone){
        ResultView<String> resultView=ResultView.FAIL();
      if (StringUtils.isNotBlank(phone)){
          boolean result = smsService.handlerSendSmsCode(phone);
          if (result){
              resultView=ResultView.SUCCESS();
          }
      }else {
          resultView.setEnumCode(Code.PARAMETER_NULL);
      }
        return resultView;
    }

}
